def set_volume(volume: int, mode: str = 'set', channel: str = 'Master'):
    import alsaaudio
    mixer = alsaaudio.Mixer(control=channel)
    if mode == 'set':
        mixer.setvolume(volume)
    elif mode == 'increase':
        volume = mixer.getvolume()[0] + volume
        mixer.setvolume(volume)
    elif mode == 'decrease':
        volume = mixer.getvolume()[0] - volume
        mixer.setvolume(volume)
    elif mode == 'get':
        return {'volume': mixer.getvolume()[0]}
    else:
        raise ValueError('Unknown volume setting mode: ' + mode)
    return {'volume': volume}

# def set_volume(volume: int, mode: str = 'set', channel: str = 'Master'):
#     import subprocess
#     import re
#     if mode == 'set':
#         subprocess.check_call(['amixer', 'set', 'Master', str(volume) + '%'])
#     elif mode == 'increase':
#         subprocess.check_call(['amixer', 'set', 'Master', str(volume) + '%+'])
#     elif mode == 'decrease':
#         subprocess.check_call(['amixer', 'set', 'Master', str(volume) + '%-'])
#     elif mode == 'get':
#         pass
#     else:
#         raise ValueError('Unknown volume setting mode: ' + mode)
#     vol = subprocess.check_output(['amixer', 'get', channel]).decode()
#     vol = re.search(r'\[(\d+)%\]', vol)
#     if vol:
#         vol = int(vol.group(1))
#     else:
#         vol = 0
#     return {'volume': vol}
